#!/bin/bash
set -e
set +o noglob
DIR="$(cd "$(dirname "$0")" && pwd)"
source $DIR/common.sh

item=0
h2 "[Step $item]: Get Docker software repository information ..."; let item+=1
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
h2 "[Step $item]: install docker-ce ..."; let item+=1
yum -y install docker-ce
h2 "[Step $item]: enable docker ..."; let item+=1
systemctl enable docker && systemctl start docker
h2 "[Step $item]: configure etc/docker/daemon.json ..."; let item+=1
cat > /etc/docker/daemon.json <<EOF
{
  "registry-mirrors": ["https://registry.cn-hangzhou.aliyuncs.com",
                                          "https://ab7b04307a8344f9a0ca5b3540aca35f.mirror.swr.myhuaweicloud.com",
                      "https://docker.1ms.run",
                      "https://docker.linkedbus.com",
                      "https://docker.xuanyuan.me"
  ],
        "insecure-registries" :["192.168.72.8:1180"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  }
}
EOF
h2 "[Step $item]: restart docker ..."; let item+=1
systemctl restart docker

